package com.ray.depot.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ray.api.service.UcenterApiService;
import com.ray.auth.system.table.entity.Dict;
import com.ray.depot.table.entity.Warehouse;
import com.ray.depot.table.entity.WarehouseType;
import com.xiaoleilu.hutool.util.ObjectUtil;



public class DictLoadUtil {

 public static  Map<String, List<Dict>> loadDict(UcenterApiService ucenterApiService, String... dictTypes) {
	//缓存
	Map<String,List<Dict>> result = new HashMap<String,List<Dict>>();
	if(ObjectUtil.isNotNull(dictTypes)){
		for(String type:dictTypes){
			List<Dict> list = ucenterApiService.queryDictsByDictType(type);	
			result.put(type, list);
		}
	}

	return result;
}

	public static List<Dict> LoadWarchouseType(List<WarehouseType> types) {
		List<Dict> list = new ArrayList<>();
		Dict dict = null;
		for(WarehouseType type:types){
			dict = new Dict();
			dict.setValue(type.getTypeId());
			dict.setName(type.getTypeName());
			list.add(dict);
		}
		return list;
	}
	
	public static List<Dict> LoadWarchouse(List<Warehouse> types) {
		List<Dict> list = new ArrayList<>();
		Dict dict = null;
		for(Warehouse type:types){
			dict = new Dict();
			dict.setValue(type.getWarchouseId());
			dict.setName(type.getWarchouseName());
			list.add(dict);
		}
		return list;
	}
	
}
